//
//  ZYCTakeSystemPhotoTool.m
//  ZDSC
//
//  Created by 张威 on 2021/10/13.
//

#import "ZYCTakeSystemPhotoTool.h"
@interface ZYCTakeSystemPhotoTool ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>

@end
@implementation ZYCTakeSystemPhotoTool

singleton_implementation(ZYCTakeSystemPhotoTool);
+ (void)cameraWillShowInController:(UIViewController *)vc
{
    _instance.delegateVC = vc;
//    UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:nil delegate:_instance cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照", @"从手机相册选择", nil];
//    action.tag = 1001;
//    [action showInView:vc.view];
    UIImagePickerController *pick = [[UIImagePickerController alloc] init];
    pick.sourceType = UIImagePickerControllerSourceTypeCamera;
    pick.delegate = self;
    [vc presentViewController:pick animated:YES completion:^{
    }];
}

+ (void)cameraWillShowInController:(UIViewController *)vc selectImage:(void (^)(UIImage *selectImg))selectBlock
{
    [self cameraWillShowInController:vc];
    _instance.SelectImage = selectBlock;
}



- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    if (self.SelectImage) {
        self.SelectImage(info[UIImagePickerControllerEditedImage]);
    }
    
    [picker dismissViewControllerAnimated:YES completion:^{
        
        [picker removeFromParentViewController];
    }];
}


@end
